#pragma once
#include "GameObject.h"
#include "GameGeometry.h"
#include <vector>
using namespace std;


// A gameobject that is renderable as multiple pieces of game geometry
class GameObject3D :
	public GameObject
{
public:
	GameObject3D(void)
	{

	}

	virtual ~GameObject3D(void)
	{
		// destroy all geometry
		for(unsigned int i=0; i<Geometry.size(); i++)
			delete Geometry[i];
	}

	// the geometry that makes up this 3D shape
	vector<GameGeometry*> Geometry;

	virtual void Render()
	{
		// for each piece of geometry..
		for(unsigned int i=0; i<Geometry.size(); i++)
		{
			// set world matrix
			D3DXMATRIXA16 worldMat = Geometry[i]->GetLocalTransform() * this->GetTransform();
			//D3DXMATRIXA16 worldMat;
			//D3DXMatrixIdentity(&worldMat);
			//worldMat = this->GetTransform();
			SimpleRender::Get().g_pd3dDevice->SetTransform( D3DTS_WORLD, &worldMat );

			// set material
			SimpleRender::Get().g_pd3dDevice->SetMaterial(&Geometry[i]->Material);

			// render
			Geometry[i]->Render();
		}
	}
};